home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Extra 1997 #1 / Amiga Plus Extra 1997 #1.iso / programme / tools / runbar / develop / source / filterc.src / filterc.c next >
C/C++ Source or Header  |  1996-11-23  |  4KB  |  150 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/runbar.h>
  5. #include <hardware/cia.h>
  6.  
  7. struct Library *RunBarBase; /* Library Base*/
  8.  
  9. /* Filter ON Image */
  10. UWORD chip fonData[39] =
  11. {
  12.     /* Plane 0 */
  13.     0x0000,0x2F90,0x1000,0x6920,0x4020,0xD6E8,0x44E0,0x64F0,
  14.     0x47E0,0x6FE0,0x1F80,0x1240,0x0000,
  15.     /* Plane 1 */
  16.     0x0000,0x2490,0x0040,0x4920,0x0710,0x9A58,0x0810,0x2C90,
  17.     0x0010,0x4920,0x0040,0x1FC0,0x0000,
  18.     /* Plane 2 */
  19.     0x0000,0x2490,0x0F80,0x5F20,0x3820,0xB768,0x2760,0x27F0,
  20.     0x00E0,0x4FE0,0x0F80,0x1240,0x0000
  21. };
  22.  
  23. struct Image fon =
  24. {
  25.     0, 0,        /* LeftEdge, TopEdge */
  26.     13, 13, 3,    /* Width, Height, Depth */
  27.     fonData,    /* ImageData */
  28.     0x0007, 0x0000,    /* PlanePick, PlaneOnOff */
  29.     NULL        /* NextImage */
  30. };
  31.  
  32. /* Filter OFF Image */
  33. UWORD chip foffData[39] =
  34. {
  35.     /* Plane 0 */
  36.     0x0000,0x0F80,0x1000,0x2000,0x4020,0x46E0,0x44E0,0x40E0,
  37.     0x47E0,0x27C0,0x1F80,0x0000,0x0000,
  38.     /* Plane 1 */
  39.     0x0000,0x0000,0x0040,0x0020,0x0710,0x0810,0x0810,0x0810,
  40.     0x0010,0x0020,0x0040,0x0F80,0x0000,
  41.     /* Plane 2 */
  42.     0x0000,0x0000,0x0F80,0x1F00,0x3820,0x3760,0x2760,0x0760,
  43.     0x00E0,0x07C0,0x0F80,0x0000,0x0000
  44. };
  45. struct Image foff =
  46. {
  47.     0, 0,        /* LeftEdge, TopEdge */
  48.     13, 13, 3,    /* Width, Height, Depth */
  49.     foffData,    /* ImageData */
  50.     0x0007, 0x0000,    /* PlanePick, PlaneOnOff */
  51.     NULL        /* NextImage */
  52. };
  53.  
  54. /* Menu Structure */
  55. struct SBItem menu[]=
  56. {
  57.   {0,"Filter OFF"}, /* 0 - Normal, 1 - Disabled */ 
  58.   {2,NULL},         /* 2 - Bar   ,15 - Menu End */
  59.   {0,"Exit"},
  60.   {15,NULL}     
  61. };
  62.  
  63. /* Information about Menu */
  64. struct RBInfo info =
  65. {
  66.   RB_VERSION,     /* Always set it to RB_VERSION*/
  67.   "FilterControl",/* Menu name.Please use specific name, because */
  68.                   /* this name will use for unique check. */
  69.   RBF_UNIQUE      /* Will not allow duplicates. */
  70. };
  71. static  char   ver[]="$VER: Filter Control by Sergej Kravcenko 1.0 (24.11.96)";
  72. /*--------------------Main Program-------------------------*/
  73. void main()
  74. {
  75.     struct CIA *cia = (struct CIA *) 0xBFE001; 
  76.     struct Task *prtask;
  77.     BOOL my_close;
  78.     struct MsgPort *port;
  79.     struct RBMessage *my_message;
  80.     ULONG  class,code,filtermode;
  81.     
  82. /*---------------Open Library------------------------------*/    
  83.     RunBarBase = (struct Library *)
  84.     OpenLibrary( "RunBar.library",1);
  85.   
  86.     if( RunBarBase == NULL) goto end;
  87.     
  88. /*------------------Get Task Pointer-----------------------*/    
  89.     prtask = FindTask(NULL);
  90.     
  91. /*------------------Create RunBar Menu---------------------*/    
  92.     if (RB_AddTask(prtask,menu,&foff,&info,&port) != 0) goto end;
  93.     
  94. /*------------------Turn filter off------------------------*/    
  95.     cia->ciapra |= 0x02;
  96.     filtermode = 0;
  97.     
  98. /*------------------Wait Port------------------------------*/    
  99.     my_close = FALSE;
  100.     while( my_close == FALSE )
  101.     {
  102.      WaitPort(port);
  103.      my_message = (struct RBMessage *) GetMsg(port);
  104.      if (my_message)
  105.      {
  106.         class    = my_message->rb_class;
  107.         code     = my_message->rb_code;
  108.         ReplyMsg((struct Message *) my_message );
  109.         
  110.         if(class == IDCMP_RUNBARCMD)
  111.          {
  112.           if (code == 2) my_close = TRUE;  
  113.           if (code == 0)
  114.           {
  115.            if (filtermode == 0)
  116.            {
  117.         /*----------Turn Filter On-----------*/    
  118.             filtermode = 1;
  119.             cia->ciapra &= 0xFD;
  120.             menu[0].sbi_Name = "Filter ON";
  121.             RB_Edit(prtask,menu,&fon);
  122.            }
  123.            else 
  124.            {
  125.         /*----------Turn Filter Off------------*/    
  126.             filtermode = 0;
  127.             cia->ciapra |= 0x02;
  128.             menu[0].sbi_Name = "Filter OFF";
  129.             RB_Edit(prtask,menu,&foff);
  130.            }
  131.           }   
  132.          } 
  133.         if (class == IDCMP_RUNBARMSG)
  134.            {
  135.        /*------------Exit--------------------*/     
  136.              if (code == RB_REMOVE) my_close = TRUE;      
  137.            }                          
  138.        
  139.      }
  140.     }
  141. /*------------Remove RunBar Menu---------------------*/
  142. /* If you get non NULL result, you must wait some time, and try */
  143. /* again. */
  144.     
  145.     while (RB_RemoveTask(prtask)) Delay(10);
  146.     
  147. /*-----------Close Library---------------------------*/    
  148. end:if ( RunBarBase ) CloseLibrary ((struct Library *) RunBarBase);   
  149. }
  150.